import time
from selenium import webdriver

def write_local_file(filename,text):
    with open(filename,"w",encoding="utf-8") as file:
        file.write(text)
        file.close()

def read_local_file(filename):
    with open(filename,"r",encoding="utf-8") as file:
        file.read(filename)
        file.close()

def fetch_website(url):
    driver = webdriver.Firefox()
    driver.get(url)
    return driver

def QZone_Login(driver):
    driver.switch_to_frame("login_frame")
    driver.find_element_by_id('switcher_plogin').click()
    driver.find_element_by_id('u').clear()
    driver.find_element_by_id('u').send_keys("1145047086")
    driver.find_element_by_id('p').clear()
    driver.find_element_by_id('p').send_keys("zl")
    driver.find_element_by_id('login_button').click()
    return driver

def driver_wait(driver):
    time.sleep(10)
    driver.quit()


if __name__ == "__main__":
    url = "https://qzone.qq.com/"
    driver = fetch_website(url)
    driver_now = QZone_Login(driver)
    driver_wait(driver_now)

